<?php

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/
Route::get('/', function () {
    return view('welcome');
});

$api = app('Dingo\Api\Routing\Router');
$api->version('v1', function ($api) {
    # 后台
    $api->group(['prefix'=>'admin','namespace'=>'App\Http\Controllers\Api\Admin','middleware'=>['crouss.request','change.admin']],function($api){
        # 初始化后台管理
        $api->post('initAdmin', 'AuthController@initAdmin');
        # 登录授权
        $api->post('login', 'AuthController@login');
        # 用户管理
        $api->group(['middleware' => 'get.user:admin'], function ($api) {
            # 文章
                # 列表
                $api->get('article','ArticleController@index');
                # 存储
                $api->post('article','ArticleController@store');
                # 编辑
                $api->get('article/{a_num}/edit','ArticleController@edit');
                # 修改
                $api->put('article/{id}','ArticleController@update');
                # 查看
                $api->get('article/{a_num}','ArticleController@show');
                # 删除
                $api->delete('article/{id}','ArticleController@destroy');
            # 文件夹管理
                # 列表
                $api->get('folder','FolderController@index');
                # 存储
                $api->post('folder','FolderController@store');
                # 修改
                $api->put('folder/{id}','FolderController@update');
                # 删除
                $api->delete('folder/{id}','FolderController@destroy');
            # 名片管理
                # 列表
                $api->get('namecard','NamecardController@index');
                # 存储
                $api->post('namecard','NamecardController@store');
                # 编辑
                $api->get('namecard/{id}/edit','NamecardController@edit');
                # 修改
                $api->put('namecard/{id}','NamecardController@update');
                # 查看
                $api->get('namecard/{id}','NamecardController@show');
                # 删除
                $api->delete('namecard/{id}','NamecardController@destroy');
            # 留言管理
                # 列表
                $api->get('message','MessageController@index');
                # 修改
                $api->put('message/{id}','MessageController@update');
                # 删除
                $api->delete('message/{id}','MessageController@destroy');
            # 文件上传管理
                $api->post('file','FileUploadController@store');
        });
    });
    # 博客
    $api->group(['prefix'=>'home','namespace'=>'App\Http\Controllers\Api\Home','middleware'=>['crouss.request']],function($api){
        # 文章
            # 列表
            $api->get('article','ArticleController@index');
            # 详情
            $api->get('article/{id}','ArticleController@show');
        # 成员
            # 列表
            $api->get('namecard','NamecardController@index');
            # 详情
            $api->get('namecard/{id}','NamecardController@show');
        # 留言管理
            # 存储
            $api->post('message','MessageController@store');
    });
});
